package weaver.interfaces.zhlx.duss.utils;

import com.alibaba.fastjson.JSONObject;
import weaver.conn.RecordSet;
import weaver.general.Util;

/**
 * @author dusongsong
 * @date 2024年11月28日 09:42
 */
public class PropUltraUtil {
    /**
     * 配置文件表
     *
     * @param bs
     * @return
     */
    public static JSONObject getPropMainVal(String bs) {
        JSONObject dataJson = new JSONObject();
        RecordSet rs = new RecordSet();
        rs.executeQuery("select id,url,username from uf_apiset where bs=?", bs);
        if (rs.next()) {
            dataJson.put("mainid", Util.null2String(rs.getString("id")));
            dataJson.put("url", Util.null2String(rs.getString("url")));
            dataJson.put("username", Util.null2String(rs.getString("username")));
        }
        return dataJson;
    }

    /**
     * 配置文件表
     *
     * @param mainid,apiName
     * @return
     */
    public static JSONObject getPropDtlVal(String mainid, String apiName) {
        JSONObject dataJson = new JSONObject();
        RecordSet rs = new RecordSet();
        rs.executeQuery("select * from uf_apiset_dt1 where mainid=? and jkmc=?", mainid, apiName);
        String [] columnNames = rs.getColumnName();
        if (rs.next()) {
            for (String columnName : columnNames) {
                String value = Util.null2String(rs.getString(columnName));
                if (!"".equals(value)) {
                    dataJson.put(columnName.toLowerCase(), value);
                }
            }
        }
        return dataJson;
    }

}
